
<%= form_tag sort_path do %>
<h2 class="title">Liste der Routen <%= select_tag :sort, options_for_select(@sort) %> <%= submit_tag "Sortieren" %></h2>
<% end %> 
<div class="content"> <!-- Content start -->
<%= link_to 'Neue Route', new_route_path %>
<table class="narrow">
	<thead>
		<tr>
    		<th>Name</th>
    		<th>Geschraubt</th>
    		<th>Grad</th>
    		<th>Umlenker</th>
    		<th>Wand</th>
    		<th>Farbe</th>
    		<th>Bauarbeiter</th>
    		<th>Eingebort</th>
    		<th>Umschrauben?</th>
    		<th>Kommentare</th>
    		<th></th>  
    		<th></th>
    		<th></th>
  		</tr>
	</thead>
	<tbody>
  		<% @routes.each do |route| %>
		<tr>
		<td><%= sanitize route.to_link %></td>
		<td><%= route.build %></td>
		<td><%= route.grade.grade %></td>
		<td><%= route.chain.number %></td>
		<td><%= route.chain.wall.to_s %></td>
		<td><%= route.color.name %></td>
		<td><%= route.workers.collect{|x| x.name}.join(", ") %></td>
		<td><span class="<%= route.existent ? "greenlabel" : "redlabel" %>"><%= route.existent ? "Ja" : "Nein" %></span></td>
		<td><%= display_redo_route(route) %></td>
		<td><%= route.comments.length > 0 ? route.comments.length : "Keine" %></td>
		<td><% if @user.is_admin? || @user.is_creator?(route) %><%= link_to 'Editieren', edit_route_path(route) %><% end %></td> 
		<td><% if @user.is_admin? %><%= link_to 'Loeschen', route, :confirm => 'Are you sure?', :method => :delete %><% end %></td>
		</tr>
		<% end %>
	</tbody>
</table>
